package com.ruoyi.classes.service.impl;

import java.util.Date;
import java.util.List;

import com.ruoyi.system.domain.TTextContent;
import com.ruoyi.system.mapper.TTextContentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.classes.mapper.TTopicMapper;
import com.ruoyi.classes.domain.TTopic;
import com.ruoyi.classes.service.ITTopicService;

/**
 * 话题Service业务层处理
 *
 * @author Bandit
 * @date 2022-11-01
 */
@Service
public class TTopicServiceImpl implements ITTopicService
{
    @Autowired
    private TTopicMapper tTopicMapper;

    @Autowired
    private TTextContentMapper tTextContentMapper;

    /**
     * 查询话题
     *
     * @param id 话题主键
     * @return 话题
     */
    @Override
    public TTopic selectTTopicById(Long id)
    {
        return tTopicMapper.selectTTopicById(id);
    }

    /**
     * 查询话题列表
     *
     * @param tTopic 话题
     * @return 话题
     */
    @Override
    public List<TTopic> selectTTopicList(TTopic tTopic)
    {
        return tTopicMapper.selectTTopicList(tTopic);
    }

    /**
     * 新增话题
     *
     * @param tTopic 话题
     * @return 结果
     */
    @Override
    public int insertTTopic(TTopic tTopic)
    {
        TTextContent tTextContent = new TTextContent();
        tTextContent.setCreateTime(new Date());
        tTextContent.setContent(tTopic.getContent());
        tTextContentMapper.insertTTextContent(tTextContent);
        tTopic.setContentId(tTextContent.getId());
        return tTopicMapper.insertTTopic(tTopic);
    }

    /**
     * 修改话题
     *
     * @param tTopic 话题
     * @return 结果
     */
    @Override
    public int updateTTopic(TTopic tTopic)
    {
        return tTopicMapper.updateTTopic(tTopic);
    }

    /**
     * 批量删除话题
     *
     * @param ids 需要删除的话题主键
     * @return 结果
     */
    @Override
    public int deleteTTopicByIds(Long[] ids)
    {
        return tTopicMapper.deleteTTopicByIds(ids);
    }

    /**
     * 删除话题信息
     *
     * @param id 话题主键
     * @return 结果
     */
    @Override
    public int deleteTTopicById(Long id)
    {
        return tTopicMapper.deleteTTopicById(id);
    }
}
